package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;

public class Demo7 {
    public static void main(String[] args) {
        try (Connection conn=DBUtil.getConnection();){
            Statement statement=conn.createStatement();
            String sql="SELECT COUNT(*) count,AVG(salary) avg_sal "+
                    "FROM teacher";
            ResultSet rs=statement.executeQuery(sql);
            while (rs.next()){
                int count=rs.getInt("count");
                double avgsal=rs.getDouble("avg_sal");
                System.out.println("员工总数："+count+" 平均工资："+avgsal);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}
